package org.anyin.gitee.cloud.center.upms.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.anyin.gitee.cloud.center.upms.mapper.SysUserMapper;
import org.anyin.gitee.cloud.center.upms.model.SysUser;
import org.anyin.gitee.cloud.center.upms.model.ext.SysUserExt;
import org.anyin.gitee.cloud.lib.core.enums.DelFlgEnum;
import org.anyin.gitee.cloud.lib.core.web.BaseRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysUserRepository extends BaseRepository<SysUserMapper, SysUser> {

    public SysUser infoByUsername(String username){
        QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
        wrapper.eq("username", username);
        return baseMapper.selectOne(wrapper);
    }

    public SysUser infoByMobile(String mobile){
        QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile", mobile);
        return baseMapper.selectOne(wrapper);
    }

    public Page<SysUserExt> page(Integer pageNo, Integer pageSize, SysUser model){
        Page<SysUserExt> page = new Page<>(pageNo, pageSize);
        List<SysUserExt> list = baseMapper.page(page, model);
        page.setRecords(list);
        return page;
    }
}
